#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "globals.h"
#include "limits.h"

// returns the id (index in the concept_names array) of a given
// concept name
int get_cid(char* cname) {
	int i = 0;
	for (i = 0; i < concept_count; ++i) {
		if (strcmp(cname,concept_names[i]) == 0) {
			return i;
		}
	}
	return -1;
}

// puts the given concept name into concept_names returns its id
int put_cname(char* cname) {
	int cid;
	/* this check is now done in create_atomic_concept method
	// first check if the cname already exists
	if ((cid = get_cid(cname)) != -1)
		return cid;
	*/
	// create a new one
	if (concept_count == MAX_CONCEPT_COUNT) {
		fprintf(stderr, "max number of concept names reached, aborting!\n");
		exit(-1);
	}
	concept_names[concept_count] = strdup(cname);
	return concept_count++;
}

// returns the id (index in the role_names array) of a given role name
int get_rid(char* rname) {
	int i = 0;
	for (i = 0; i < role_count; ++i) {
		if (strcmp(rname,role_names[i]) == 0) {
			return i;
		}
	}
	return -1;
}

// puts the given role name into role_names and returns its id
int put_rname(char* rname) {
	int rid;
	if (role_count == MAX_ROLE_COUNT) {
		fprintf(stderr, "max number of role names reached, aborting!\n");
		exit(-1);
	}
	role_names[role_count] = strdup(rname);
	return role_count++;
}
